#include "ppSpline.h"
#include <cmath>

// 单位圆拟合测试(线性插值+三次complete)
int main(){
    cout << "-----testCircle-----\n";
    const double r = 1;
    const double a = 0.5 * r;
    const double b = sqrt(3)/2 * r;
    vector<vector<double>> knots = {
        {r,0}, {a,b}, {-a,b},
        {-r,0}, {-a,-b}, {a,-b}, {r,0},
    };

    // 单位圆的弧长参数为t, 其中x=cost, y=sint.
    vector<double> left_bound = {0, 1};
    vector<double> right_bound(left_bound);

    vector<ppSpline<1>> linearPPS = solver(knots);
    vector<ppSpline<3>> cubicCplPPS = solver(knots, complete, 
                                        left_bound, right_bound);

    {
        string filename = "output/testCircle_data/linearPPS.txt";
        ofstream output(filename);
        if(output.is_open()){
            print_dis_pt_data(linearPPS, 200, output);
            output.close();
            cout << "File " << filename;
            cout << " created and written successfully.\n";
        }
        else{  
            cout << "Error creating file: " << filename << ".\n";  
        }
    }

    {
        string filename = "output/testCircle_data/cubicCplPPS.txt";
        ofstream output(filename);
        if(output.is_open()){
            print_dis_pt_data(cubicCplPPS, 200, output);
            output.close();
            cout << "File " << filename;
            cout << " created and written successfully.\n";
        }
        else{  
            cout << "Error creating file: " << filename << ".\n";  
        }
    }
    return 0;
}